using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;

namespace IQIGame.Onigao.GamePlay
{
    public class UIN_HeroUpLevelAttribute : UIBaseNode
    {
        #region Template Generate,don't modify
        protected class UIB_UIN_HeroUpLevelAttribute
        {
            #region ObjectBinding Generate 
            public IQIGame.Onigao.Framework.ExImage icon { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textName { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textCurent { protected set; get; }
            public IQIGame.Onigao.Framework.ExText textLast { protected set; get; }
            public virtual void InitBinding(ObjectBinding __binding)
            {
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExImage>("icon", out var __tbv0);
                this.icon = __tbv0;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textName", out var __tbv1);
                this.textName = __tbv1;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textCurent", out var __tbv2);
                this.textCurent = __tbv2;
                __binding.TryGetVariableValue<IQIGame.Onigao.Framework.ExText>("textLast", out var __tbv3);
                this.textLast = __tbv3;
            }


            #endregion ObjectBinding Generate 
        }
        #endregion Template Generate,don't modify

        #region fields



        #endregion fields

        #region properties

        protected UIB_UIN_HeroUpLevelAttribute ui { get; set; }
        protected UIMsgDispatcher uiMsgDispatcher => this._msgDispatcher as UIMsgDispatcher;

        #endregion properties

        protected override void BeforeInit()
        {
            ui = new UIB_UIN_HeroUpLevelAttribute();
            ui.InitBinding(this.csObjBind);
        }

        protected override void OnInit()
        {

        }

        protected override void OnShow()
        {

        }

        protected override void OnHide()
        {

        }

        /// <summary>
        /// 添加UGUI侦听
        /// </summary>
        protected override void AddUGUIListener()
        {

        }

        /// <summary>
        /// 添加全局侦听（MsgDispatcher）
        /// </summary>
        protected override void AddMsgListeners()
        {

        }

        protected override void OnDispose()
        {

        }

        #region methonds

        public void Show(int cid, int last, int current)
        {
            var cfg = TableCenter.attribute.Get(cid);
            if (cfg == null)
            {
                Hide();
                return;
            }
            this.Show();
            this.SetImageSprite(this.ui.icon, cfg.Icon_fullPath);
            this.ui.textLast.text = last.ToString();
            this.ui.textCurent.text = current.ToString();
        }
        #endregion methonds
    }
}
